package com.itcast.peft.mapper;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.apache.ibatis.annotations.Mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcast.peft.entity.Question;

@Mapper
public interface QuestionMapper extends BaseMapper<Question> {
    
    public default Map<Long, Question> id2data(String batchId) {
        return selectListByBatchId(batchId).stream().collect(Collectors.toMap(Question::getId, Function.identity()));
    }
    
    public default List<Question> selectListByBatchId(String batchId) {
        LambdaQueryWrapper<Question> wp = new LambdaQueryWrapper<>();
        wp.eq(Question::getBatchId, batchId);
        return this.selectList(wp);
    }
}